<?php
// no direct access
defined( '_AppMiage' ) or die( 'Restricted access' );
if(isEntreprise ()){
    //include header
    include_once (DS.'include/header.php');
    //include menu
    include_once (DS.'include/menu.php');

    $showOK = false;
    $showError = false;

    if(isset($_POST['submit']) && !empty($_POST['submit'])){

            // variable qui va nous servir pour savoir s'il y a a eu une erreur ;)
        $form = true;
        $errMSG = array();

            //V�rification et ajout de la nouvelle technologie puis l'ajout de la technologie � la liste des technologie de l'offre
            if(isset($_POST['IG']['statut']) && !empty($_POST['IG']['statut']))
            {
                    $offre= new Offre($_POST['IG']['statut']);
                    $offre->setStatutOffre('pourvue');
                    $offre->updateOffre();

            if($tmp['boolOk'] === false)
            {
                $errMSG['IG']['statut'] = $tmp['errmsg'];
                $form = false;
            }
            }
    }
    ?>
    <div id="content">
        <div class="post">
            <div class="entry">
                <h3 class="title">Liste des Offres </h3>
                <?php if (isset($_GET['ok']) && $_GET['ok'] == "1"): ?>
                      <div class="success">L'offre a correctement &eacute;t&eacute; enregistr&eacute;e.</div>
                <?php endif; ?>
            </div>
            <form method="post" action="<?php echo URL; ?>index.php?m=app_entreprise_historiqueoffre" id="custom">
            <div class="entry">
                <?php
                $listeoffre = Offre::getListOffreByNom($global_member->getIdUtilisateur());

                if (!empty($listeoffre))
                {
                ?>
                    <table width="100%">
                        <thead>
                            <tr>
                                <th style="background-color:#64991E; color:#FFF">Titre Offre</th>
                                <th style="background-color:#64991E; color:#FFF">D&eacute;but</th>
                                <th style="background-color:#64991E; color:#FFF">Fin</th>
                                <th style="background-color:#64991E; color:#FFF">Poste(s)</th>
                                <th style="background-color:#64991E; color:#FFF">Statut</th>
                                <th style="background-color:#64991E; color:#FFF"></th>
                                <th style="background-color:#64991E; color:#FFF">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                        foreach ($listeoffre as $u)
                        {
                            $viewURL = URL."/index.php?m=app_entreprise_viewoffre&uid=".$u->IdOffre;
                            ?>
                            <tr >
                                <td style="text-align:center"><?php echo stripslashes($u->TitreOffre); ?></td>
                                <td style="text-align:center"><?php echo date('d/m/y',$u->DateDebutOffre); ?></td>
                                <td style="text-align:center"><?php echo date('d/m/y',$u->DateFinOffre); ?></td>
                                <td style="text-align:center"><?php echo $u->NombrePosteDispoOffre; ?></td>
                                <td style="text-align:center"><?php echo $u->StatutOffre; ?></td>
                                <td style="text-align:center"><input type="checkbox" id="IG[statut-<?php echo $u->IdOffre; ?>]" name="IG[statut][]" value="<?php echo $u->IdOffre; ?>" /></td>
                                <td style="text-align:center">
                                <a href="<?php echo $viewURL; ?>">
                                    <img src="<?php echo STYLEBK; ?>img/icons/report.png" title="D&eacute;tails de l'offre" width="16" height="16" />
                                </a>
                                </td>
                            </tr>
                        <?php
                        }
                        ?>
                        </tbody>
                    </table>
                    <div align="center">
                            <input class="button green" type="submit" disable="disable" value="Passer comme pourvue" name="submit">
                    </div>
                <?php
                }
                else
                {
                    echo 'rien';
                }
                ?>

            </div>
            </form>
        </div>
    </div>
    <?php
    include_once (DS.'include/sidebar.php');
    include_once (DS.'include/footer.php');
}
else
{
    redirectTo();
}
?>